#include <iostream>

using namespace std;

int main() {
    int n;
    cin >> n;
    int *nums = new int[n];
    for (int i = 0; i < n; ++i) {
        cin >> nums[i];
    }

    for (int i = 0; i < n; ++i) {
        if (i < 2) {
            cout << 0 << " ";
            continue;
        }
        int count = 0;
        for (int j = i - 1; i >= 0; j--) {
            if (nums[j] > nums[i]) {
                count++;
            }
            if (count == 2) {
                cout << j + 1 << " ";
                break;
            }
        }
        if (count < 2) {
            cout << 0 << " ";
        }
    }
    cout << endl;
    return 0;
}